其他
大佬深夜怒爬某 Hub 站资源,只为撸这个鉴黄平台!
点击上方“民工哥技术之路”,选择“设为星标”
回复“1024”获取独家整理的学习资料!
# 数据准备
# 账号准备
1、使用如下链接注册账号
2、创建 UAI-Censor 应用
3、获取公钥、私钥,应用ID
https://console.ucloud.cn/uapi/apikey
点击显示即可查看公钥私钥了
4、编码
实在不忍直视啊,我就打码了,不过看到 forbid了吗
/**
* @param imageUrl
* @return pass-放行, forbid-封禁, check-人工审核
* @throws Exception
*/
public String check(String imageUrl) {
String ucloudUrl = "http://api.uai.ucloud.cn/v1/image/scan";
String appId = "uaicensor-rjmvogpx";
String uaicensorPublicKey = null;
String uaicensorPrivateKey = null;
//图片绝对路径
RestTemplate rest = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
/**
* 生成signature,首字母排序
*/
String timestamp = System.currentTimeMillis() + "";
SortedMap<Object, Object> packageParams = new TreeMap<>();
packageParams.put("PublicKey", uaicensorPublicKey);
packageParams.put("ResourceId", appId);
packageParams.put("Timestamp", timestamp);
packageParams.put("Url", imageUrl);
String signature = null;
try {
signature = UCloudUtil.createSign(packageParams, uaicensorPrivateKey);
} catch (Exception e) {
return null;
}
/**
* 参数
*/
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("Scenes", "porn");
param.add("Method", "url");
param.add("Url", imageUrl);
/**
* headers 参数
*/
headers.setContentType(MediaType.parseMediaType("multipart/form-data; charset=UTF-8"));
headers.set("PublicKey", uaicensorPublicKey);
headers.set("Signature", signature);
headers.set("ResourceId", appId);
headers.set("Timestamp", timestamp);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(param, headers);
ResponseEntity<String> responseEntity = rest.exchange(ucloudUrl, HttpMethod.POST, httpEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSON.parseObject(body);
if (jsonObject.getInteger("RetCode") == 0) {
String res = jsonObject.getJSONObject("Result").getJSONObject("Porn").getString("Suggestion");
return res;
}
return null;
}
来源:码匠笔记
最新整理的 2TB 干货资源,包括但不限于:Linux运维、架构师、大数据、Docker、数据库、redis、MongoDB、电子书、Java、机器学习、BAT面试精讲视频等。在公众号对话框回复「1024 」即可免费获取!!